$(function () {
  $('.app_down,.down-code').hover(function () {
    $('.down-code').stop().fadeToggle();
  });
  // 无缝隙滚动切换
  var mySwiper = new Swiper('.dection_comment-list', {
    direction: 'vertical', // 垂直切换选项
    loop: true, // 循环模式选项
    delay:500,
    slidesPerView: 3,
    autoplay: {
      delay: 500,//1秒切换一次\
      pauseOnMouseEnter: true,
    },
  });
  
  // 新闻系列切换
  var news = new Swiper('.main_top-right', {
    autoplay: {
      delay:5000,
      pauseOnMouseEnter: true,
    }, //可选选项，自动滑动
    loop: true, // 循环模式选项
    // 如果需要分页器
    pagination: {
      el: '.swiper-pagination',
      clickable :true,
    },
    on:{
      slideChangeTransitionEnd:function(){
        mySwiper.forEach(function(item){
          item.autoplay.start();
        })
      }
    }
  });
  news.el.onmouseover = function(){
    news.autoplay.stop();
  }
  news.el.onmouseout = function(){
    news.autoplay.start();
  }

  //qa
  // var qa = new Swiper ('.swiper_main', {
  //   autoplay: 5000,//可选选项，自动滑动
  //   loop: true, // 循环模式选项
  //     // 如果需要分页器
  //   pagination: {
  //     el: '.swiper-pagination',
  //   },
  // })
  var swiper = new Swiper('.swiper_main', {
    loop: true,
    loopedSlides: 5,
    slidesPerView: 'auto',
    autoplay: false,
    centeredSlides: true,
    initialSlide: 4,
    watchSlidesProgress: true,
    on: {
      progress: function (progress) {
        for (i = 0; i < this.slides.length; i++) {
          var slide = this.slides.eq(i);
          var slideProgress = this.slides[i].progress;
          if (Math.abs(slideProgress) > 1) {
            var modify = (Math.abs(slideProgress) - 1) * 0.8 + 1;
          }
          translate = slideProgress * modify * 328 + 'px';
          scale = 1 - Math.abs(slideProgress) / 4;
          zIndex = 999 - Math.abs(Math.round(10 * slideProgress));
          slide.transform('translateX(' + translate + ') scale(' + scale + ')');
          slide.css('zIndex', zIndex);
          slide.css('opacity', 1);
          if (Math.abs(slideProgress) > 3) {
            slide.css('opacity', 0);
          }
        }
      },
      setTransition: function (transition) {
        for (var i = 0; i < this.slides.length; i++) {
          var slide = this.slides.eq(i);
          slide.transition(transition);
        }
      },
    },
    navigation: {
      nextEl: '.swiper-button-next',
      prevEl: '.swiper-button-prev',
    },
  });
});
